package com.example.remindme.RemindDatabase

import androidx.lifecycle.LiveData
import androidx.room.*

@Dao
interface MatterDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertRegister(entity: MatterEntity)
    @Delete
    fun deleteAccount(entity: MatterEntity)
    // 删除数据对应的是某个实体
    @Update
    fun updateAccount(entity: MatterEntity)
    @Query("select * from matters where matterType=:type")
    fun getByType(type:String):LiveData<List<MatterEntity> >  // 通过列表的类型进行选择

    @get:Query("select * from matters ")
    val AllMatters: LiveData<List<MatterEntity>>

    @Query("select * from matters")
    fun getAll():LiveData<List<MatterEntity>>
    // 查询当前有的列表
    @Query("select * from matters where isFlag=1")
    fun getMattersFlaged():LiveData<List<MatterEntity>>

    @Query(" select count(*) from matters where isflag=1")
    fun getFlagNum():Int

    @Query(" select count(*) from matters where timed>0")
    fun getScheduledNum():Int

    @Query(" select count(*) from matters")
    fun getAllNum():Int

    @Query("select DISTINCT matterType from matters ")
    fun getListNum():List<String>

    @Query("select * from matters where timed>10")
    fun getMatterTimed():LiveData<List<MatterEntity>>
}


@Dao
interface ListDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertRegister(entity: ListEntity)
    @Delete
    fun deleteAccount(entity: ListEntity)
    // 删除数据对应的是某个实体
    @Update
    fun updateAccount(entity: ListEntity)
    // 查询当前有多少个列表
    @Query("select count(*) from mylist ")
    fun getListNum():Int
    @Query("select * from mylist")
    fun getAll():List<ListEntity>
    @get:Query("select * from mylist ")
    val allTypeList: LiveData<List<ListEntity>>
}

